package com.travel.ticket.web;

import com.alibaba.fastjson.JSON;
import com.travel.common.vo.MemberRespVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import static com.travel.common.constant.AuthServerConstant.LOGIN_USER;

@Controller
public class PageController {

    @Autowired
    StringRedisTemplate redisTemplate;

    @RequestMapping({"/"})
    public String ticketIndex(Model model){
        //TODO 获取当前热卖的票

        //TODO 获取当前参与秒杀活动的票

        //从reids中获取当前用户
        String user = redisTemplate.opsForValue().get(LOGIN_USER);
        MemberRespVo loginUser = JSON.parseObject(user, MemberRespVo.class);

        model.addAttribute("loginUser",loginUser);
        return "ticketIndex";
    }

}
